package com.example.exampleproject.controller;


import com.example.exampleproject.entity.EmploymentIndustryEntity;
import com.example.exampleproject.service.EmploymentIndustryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
public class EmploymentIndustryController {//控制层


    @Autowired
    EmploymentIndustryService  service;
    //get方法直接放路径,如：http://127.0.0.1:8081/getEmploymentIndustryListByYear/2021
    @GetMapping( value = "/getEmploymentIndustryListByYear/{year}" )
    public List<EmploymentIndustryEntity>  getEmploymentIndustryListByYear(@PathVariable("year") Integer year){

        return service.getEmploymentIndustryListByYear(year);

    }
    //get方法链接传参,如：http://127.0.0.1:8081/getEmploymentIndustryListByYear2?year=2021
    @GetMapping( value = "/getEmploymentIndustryListByYear2" )
    public List<EmploymentIndustryEntity>  getEmploymentIndustryListByYear2(@RequestParam("year") Integer year){
        return service.getEmploymentIndustryListByYear(year);

    }

    //POST请求
    @PostMapping("/getEmploymentIndustryListByYear")
    public List<EmploymentIndustryEntity>  getEmploymentIndustryListByYear(@RequestBody() Map<String,Object> prams){
        Integer year = (Integer) prams.get("year");
        return service.getEmploymentIndustryListByYear(year);

    }

}
